﻿using UnityEngine;
using System.Collections;

/// <summary>
/// 影子管理器
/// </summary>
public class ShadowManager : MonoBehaviour {
    /// <summary>
    /// 影子预置体
    /// </summary>
    public GameObject ShadowPrefab;
    /// <summary>
    /// 单例对象
    /// </summary>
    public static ShadowManager Instance;
    public bool Show = false;
	// Use this for initialization
	void Awake () {
        Instance = this;
	}

    /// <summary>
    /// 设置影子是否显示
    /// </summary>
    /// <param name="show">是否显示</param>
    public void ShowShadow(bool show)
    {
        if (show == Show)
            return;
        Show = show;
        BroadcastMessage("ShowShadowMesh", show);
    }

    /// <summary>
    /// 激活影子或使影子失效
    /// </summary>
    /// <param name="enable">true=激活，false=失效</param>
    public void EnableShadows(bool enable)
    {
        int shadowsCount = transform.childCount;
        for (int i = 0; i < shadowsCount; i++)
        {
            transform.GetChild(i).gameObject.SetActive(enable);
        }
    }
}
